package com.ms.str.param;

/**
 * @author carter
 * create time    2018-08-14
 */
public class TestParam {
    public void changeInt(int a)
    {
        a = 3;
    }

    public void changePoint(Point point)
    {
        point.x = 5;
        point.y = 6;
    }

    public void changeString(String str)
    {
        System.out.println("2," + str.hashCode());
        str = "hello world";
        System.out.println("3,"+str.hashCode());
    }


    /**
     * 原生类型,引用类型 一律传递的是值；
     *
     * int 传 3；
     * point 传递地址值；
     *
     *
     * @param args
     */
    public static void main(String[] args) {

        TestParam testParam = new TestParam();
//        testInt(testParam);

//        testPoint(testParam);


        String str ="xyz";
        System.out.println("1," + str.hashCode());
        testParam.changeString(str);
        System.out.println(str);//xyz


    }

    private static void testPoint(TestParam testParam) {
        Point poinit = new Point(1,2);

        testParam.changePoint(poinit);

        System.out.println(poinit.x + " , " + poinit.y);// 5,6
    }

    private static void testInt(TestParam testParam) {
        int a = 1;
        testParam.changeInt(a);
        System.out.println(a);// 1


    }
}


class Point{

    int x;int y;

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
}
